using System;
using System.Collections;
using System.Data.SQLite;
using System.Windows.Forms;
public class EventGoodsUtil
{
	public SQLiteCommand sqliteCommand_0;
	public SQLiteCommand sqliteCommand_1;
	public SQLiteCommand sqliteCommand_2;
	public SQLiteCommand sqliteCommand_3;
	public SQLiteConnection sqliteConnection_0;
	public string string_0 = Application.StartupPath;
	public EventGoodsUtil()
	{
		this.method_0();
	}
	public void method_0()
	{
		if (this.sqliteConnection_0 == null)
		{
			this.sqliteConnection_0 = new SQLiteConnection("Data Source=" + this.string_0 + "\\config\\alibridge.db;Version=3;Pooling=true");
			this.sqliteConnection_0.Open();
		}
	}
	public bool method_1(EventGoods eventGoods, out string string_1)
	{
		bool result;
		try
		{
			string text = "INSERT INTO bridgeitem(eventId, itemId, itemTitle,  commissionRate, isSoldOut, discountPrice, auctionPrice, soldQuantity, mall, actCmsRate, actEarn, startTime) VALUES ('{eventId}','{itemId}','{itemTitle}', {commissionRate},{isSoldOut},{discountPrice},'{auctionPrice}',{soldQuantity},{mall},{actCmsRate},{actEarn},{startTime});";
			text = text.Replace("{eventId}", eventGoods.event_id).Replace("{itemId}", eventGoods.num_iid).Replace("{itemTitle}", eventGoods.title.Replace("'", "").Replace("\t", "").Replace("\n", "")).Replace("{commissionRate}", string.Concat(eventGoods.commission_rate)).Replace("{isSoldOut}", string.Concat(eventGoods.is_sold_out)).Replace("{discountPrice}", string.Concat(eventGoods.price)).Replace("{auctionPrice}", eventGoods.ori_price ?? "").Replace("{soldQuantity}", string.Concat(eventGoods.volume)).Replace("{mall}", string.Concat(eventGoods.is_mall)).Replace("{actCmsRate}", string.Concat(eventGoods.actCmsRate)).Replace("{actEarn}", string.Concat(eventGoods.actEarn)).Replace("{startTime}", string.Concat(eventGoods.startTime));
			if (this.sqliteCommand_0 == null)
			{
				this.sqliteCommand_0 = new SQLiteCommand(text, this.sqliteConnection_0);
			}
			else
			{
				this.sqliteCommand_0.CommandText = text;
			}
			this.sqliteCommand_0.ExecuteNonQuery();
			string_1 = "";
			result = true;
		}
		catch (Exception ex)
		{
			string_1 = "出错啦！" + ex.ToString();
			result = false;
		}
		return result;
	}
	public ArrayList method_10(string string_1, out string string_2)
	{
		string string_3 = "select * from bridgeinfo where eventId='" + string_1 + "'";
		return this.method_11(string_3, out string_2);
	}
	public ArrayList method_11(string string_1, out string string_2)
	{
		ArrayList result;
		try
		{
			ArrayList arrayList = new ArrayList();
			if (this.sqliteCommand_1 == null)
			{
				this.sqliteCommand_1 = new SQLiteCommand(string_1, this.sqliteConnection_0);
			}
			else
			{
				this.sqliteCommand_1.CommandText = string_1;
			}
			SQLiteDataReader sQLiteDataReader = this.sqliteCommand_1.ExecuteReader();
			while (sQLiteDataReader.Read())
			{
				arrayList.Add(new EventItem
				{
					event_id = sQLiteDataReader["eventId"].ToString(),
					start_time = int.Parse(sQLiteDataReader["startTime"].ToString()),
					end_time = int.Parse(sQLiteDataReader["endTime"].ToString()),
					avg_commission = double.Parse(sQLiteDataReader["avgCommission"].ToString()),
					share_rate = double.Parse(sQLiteDataReader["shareRate"].ToString())
				});
			}
			string_2 = "";
			sQLiteDataReader.Close();
			result = arrayList;
		}
		catch (Exception ex)
		{
			string_2 = "出错啦：" + ex.ToString();
			result = new ArrayList();
		}
		return result;
	}
	public ArrayList method_12(string string_1, out string string_2)
	{
		ArrayList result;
		try
		{
			string str = "'" + string_1.Replace(",", "', '") + "'";
			string commandText = "select eventId from bridgeinfo where eventId in (" + str + ");";
			ArrayList arrayList = new ArrayList();
			if (this.sqliteCommand_1 == null)
			{
				this.sqliteCommand_1 = new SQLiteCommand(commandText, this.sqliteConnection_0);
			}
			else
			{
				this.sqliteCommand_1.CommandText = commandText;
			}
			SQLiteDataReader sQLiteDataReader = this.sqliteCommand_1.ExecuteReader();
			while (sQLiteDataReader.Read())
			{
				arrayList.Add(sQLiteDataReader["eventId"].ToString());
			}
			string_2 = "";
			sQLiteDataReader.Close();
			result = arrayList;
		}
		catch (Exception ex)
		{
			string_2 = "出错啦：" + ex.ToString();
			result = new ArrayList();
		}
		return result;
	}
	public bool method_13(string string_1, out string string_2)
	{
		bool result;
		try
		{
			if (this.sqliteCommand_3 == null)
			{
				this.sqliteCommand_3 = new SQLiteCommand(string_1, this.sqliteConnection_0);
			}
			else
			{
				this.sqliteCommand_3.CommandText = string_1;
			}
			this.sqliteCommand_3.ExecuteNonQuery();
			string_2 = "";
			result = true;
		}
		catch (Exception ex)
		{
			string_2 = "出错啦：" + ex.ToString();
			result = false;
		}
		return result;
	}
	public void method_14()
	{
		try
		{
			string text = "";
			string string_ = "vacuum";
			this.method_13(string_, out text);
		}
		catch
		{
		}
	}
	public ArrayList method_2(string string_1, string string_2, out string string_3)
	{
		string string_4 = "select * from bridgeitem where itemTitle like '%" + string_1 + "%' " + string_2;
		return this.method_6(string_4, out string_3);
	}
	public ArrayList method_3(string string_1, string string_2, out string string_3)
	{
		string string_4 = "select * from bridgeitem where eventId='" + string_1 + "' " + string_2;
		return this.method_6(string_4, out string_3);
	}
	public ArrayList method_4(string string_1, string string_2, out string string_3)
	{
		string string_4 = "select * from bridgeitem where itemId='" + string_1 + "' " + string_2;
		return this.method_6(string_4, out string_3);
	}
	public ArrayList method_5(string string_1, string string_2, out string string_3)
	{
		string string_4 = string.Concat(new string[]
		{
			"select * from bridgeitem where eventId='",
			string_1,
			"' and itemId='",
			string_2,
			"'"
		});
		return this.method_6(string_4, out string_3);
	}
	public ArrayList method_6(string string_1, out string string_2)
	{
		ArrayList result;
		try
		{
			ArrayList arrayList = new ArrayList();
			if (this.sqliteCommand_1 == null)
			{
				this.sqliteCommand_1 = new SQLiteCommand(string_1, this.sqliteConnection_0);
			}
			else
			{
				this.sqliteCommand_1.CommandText = string_1;
			}
			SQLiteDataReader sQLiteDataReader = this.sqliteCommand_1.ExecuteReader();
			while (sQLiteDataReader.Read())
			{
				arrayList.Add(new EventGoods
				{
					event_id = sQLiteDataReader["eventId"].ToString(),
					num_iid = sQLiteDataReader["itemId"].ToString(),
					title = sQLiteDataReader["itemTitle"].ToString(),
					commission_rate = double.Parse(sQLiteDataReader["commissionRate"].ToString()),
					is_sold_out = int.Parse(sQLiteDataReader["isSoldOut"].ToString()),
					price = double.Parse(sQLiteDataReader["discountPrice"].ToString()),
					ori_price = sQLiteDataReader["auctionPrice"].ToString(),
					volume = int.Parse(sQLiteDataReader["soldQuantity"].ToString()),
					is_mall = int.Parse(sQLiteDataReader["mall"].ToString()),
					actCmsRate = double.Parse(sQLiteDataReader["actCmsRate"].ToString()),
					actEarn = double.Parse(sQLiteDataReader["actEarn"].ToString()),
					startTime = int.Parse(sQLiteDataReader["startTime"].ToString())
				});
			}
			string_2 = "";
			sQLiteDataReader.Close();
			result = arrayList;
		}
		catch (Exception ex)
		{
			string_2 = "出错啦：" + ex.ToString();
			result = new ArrayList();
		}
		return result;
	}
	public ArrayList method_7(string string_1, out string string_2)
	{
		ArrayList result;
		try
		{
			ArrayList arrayList = new ArrayList();
			if (this.sqliteCommand_1 == null)
			{
				this.sqliteCommand_1 = new SQLiteCommand(string_1, this.sqliteConnection_0);
			}
			else
			{
				this.sqliteCommand_1.CommandText = string_1;
			}
			SQLiteDataReader sQLiteDataReader = this.sqliteCommand_1.ExecuteReader();
			while (sQLiteDataReader.Read())
			{
				arrayList.Add(new GoodsItem
				{
					num_iid = sQLiteDataReader["itemId"].ToString()
				});
			}
			string_2 = "";
			sQLiteDataReader.Close();
			result = arrayList;
		}
		catch (Exception ex)
		{
			string_2 = "出错啦：" + ex.ToString();
			result = new ArrayList();
		}
		return result;
	}
	public bool method_8(string string_1, out string string_2)
	{
		bool result;
		try
		{
			string text = "update bridgeitem set excellence=1 where eventId in({eventidlist});";
			text = text.Replace("{eventidlist}", string_1);
			if (this.sqliteCommand_2 == null)
			{
				this.sqliteCommand_2 = new SQLiteCommand(text, this.sqliteConnection_0);
			}
			else
			{
				this.sqliteCommand_2.CommandText = text;
			}
			this.sqliteCommand_2.ExecuteNonQuery();
			string_2 = "";
			result = true;
		}
		catch (Exception ex)
		{
			string_2 = "出错啦！" + ex.ToString();
			result = false;
		}
		return result;
	}
	public bool createEvent(EventItem eventItem, out string string_1)
	{
		bool result;
		try
		{
			string text = "INSERT INTO bridgeinfo(eventId, startTime, endTime, avgCommission, shareRate) VALUES ('{eventId}',{startTime},{endTime},{avgCommission},{shareRate});";
			text = text.Replace("{eventId}", eventItem.event_id).Replace("{startTime}", string.Concat(eventItem.start_time)).Replace("{endTime}", string.Concat(eventItem.end_time)).Replace("{avgCommission}", string.Concat(eventItem.avg_commission)).Replace("{shareRate}", string.Concat(eventItem.share_rate));
			if (this.sqliteCommand_0 == null)
			{
				this.sqliteCommand_0 = new SQLiteCommand(text, this.sqliteConnection_0);
			}
			else
			{
				this.sqliteCommand_0.CommandText = text;
			}
			this.sqliteCommand_0.ExecuteNonQuery();
			string_1 = "";
			result = true;
		}
		catch (Exception ex)
		{
			string_1 = "出错啦！" + ex.ToString();
			result = false;
		}
		return result;
	}
}
